package com.cyandpos.pad.presentation;


import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

public class PresentationPagerAdapter extends PagerAdapter {
    private List<View> list;

    public  PresentationPagerAdapter(List<View> list){
        this.list=list;
    }
    @Override
    public int getCount() {
        if(list!=null) {
            return list.size();
        }
        return 0;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position,
                            Object object) {
        container.removeView(list.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        View view=list.get(position);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("TAG","position==="+position);
            }
        });
        container.addView(view);
        return list.get(position);
    }
}
